import { BasicColumn } from '/@/components/Table/src/types/table';
import { FormSchema } from '/@/components/Table';
import { Tag } from "ant-design-vue";
import { h, ref } from 'vue';
import { router } from '/@/router/index';

let path = ref('')

path.value = router.currentRoute.value.path
//console.log('path=', path.value)
//console.log('path2=', window.location.href)

//查询条件
export const searchFormSchema: FormSchema[] = [
  {
    field: 'keyword',
    label: '关键字',
    component: 'Input',
    componentProps: {
      placeholder: '请输入名称/编码',
    },
    labelWidth: 60,
    colProps: { span: 6, lg: { span: 6, offset: 0 }, sm: { span: 10, offset: 0 }, xs: { span: 16, offset: 0 } },
  },
  {
    field: 'dateRange',
    label: '时间范围',
    component: 'RangePicker',
    labelWidth: 80,
    colProps: { span: 6, lg: { span: 6, offset: 0 }, sm: { span: 10, offset: 0 }, xs: { span: 16, offset: 0 } },
  },

  {
    field: 'status',
    label: '流程状态',
    ifShow: false,
    component: 'Input',
  },

];


/**
 * 表格列定义
*/
export const TableSchema: BasicColumn[] = [
  {
    title: '标题',
    dataIndex: 'title',
  },
  {
    title: '摘要',
    dataIndex: 'summary',
  },
  {
    title: '发起人',
    dataIndex: 'operatorName',
    customRender: ({ record }) => {
      const color = 'green';
      const text = record.operatorName;
      return h(Tag, { color: color }, () => text);
    },
  },
  {
    title: '发起时间',
    dataIndex: 'startTime',
  },
  {
    title: '完成时间',
    dataIndex: 'stopTime',
  },
  {
    title: '流程状态',
    dataIndex: 'statusName',
    customRender: ({ record }) => {
      const color = record.status === 20 ? 'red' : 'green';
      const text = record.statusName;
      return h(Tag, { color: color }, () => text);
    },
  },
];


/**
 * 表单字段定义
*/
export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: 'ID',
    component: 'Input',
    show: false,
  },
  {
    field: 'formNo',
    label: '表单编号',
    component: 'Input',
  },

  {
    field: 'reasonNo',
    label: '编号',
    required: true,
    component: 'Input',
  },
  {
    field: 'detailList',
    label: '拓展信息',
    component: 'Input',
    slot: 'detailList',
  },
  {
    field: 'aaList',
    label: '审批人',
    component: 'Input',
    slot: 'addOperator',
  },
  {
    field: 'ccList',
    label: '抄送人',
    component: 'Input',
    slot: 'addCCOperator',
  }
];




